package com.atguigu;

public class Test3 {

	public static void main(String[] args) {
		final En en = new En();
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				for (int i = 0; i < 26; i++) {
					en.printNum();
					
				}
			}
		}, "AA").start();
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				for (int i = 0; i < 26; i++) {
					
					en.printLet();
				}
				
			}
		}, "BB").start();
		
	}
	
	
	
}

class En{
	private int num = 0;
	private int i = -1;
	public synchronized void printNum(){
		notify();
		System.out.print(++ num);
		System.out.print(++ num);
		try {
			wait();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public synchronized void printLet(){
		notify();
		System.out.print((char)('A' + ++i));
		try {
			wait();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	
}
